GBML manual / Rooms

door_is_locked

True if the door whose own door_id is door is currently locked. door may be the door’s own name (given it in the Room Editor) - resolved to its door_id at compile time, for free - or a door_id int, literal or computed.

Syntax

door_is_locked(door) -> bool

Arguments

NameType
doordoor

Returns

bool

Description

True if the door whose own door_id is door is currently locked. Reads back the same value door_lock/door_unlock write. door accepts a door's own NAME (resolved to its door_id at compile time) or a plain door_id int, exactly like door_lock/door_unlock - see door_lock's own description for the full reasoning.

A locked door still works as an Exit. Locking a door blocks SENDING only - acting as an Enter door - never receiving. A locked door can still be arrived at, the same as an unlocked one; only walking INTO it (to be sent somewhere) is blocked. This is deliberate: if locking also blocked arrival, locking one door could break a completely different door elsewhere whose own destination is this one, with no good answer for where the player should end up instead. So before writing code that treats "locked" as "cannot be reached at all," check which side of the door the question is actually about - door_is_locked only ever answers "can this door currently send."

Reads back false for a door_id naming no live instance right now (see the Limits section below) - the same value an unlocked door reports. There is no separate "not found" result.

Example

if (door_is_locked(2)) {
    draw_text_anchored(ANCHOR_TOP_LEFT, 4, 4, "LOCKED");
}

Shows a small label whenever the door with door_id 2 is currently locked - a common HUD hint for a door a player has not yet found the key to.

Limits

Same current-room-only limit as door_lock: a door instance is never persistent, so a door_id belonging to a room that is not the one currently loaded is not a live instance of anything right now, and this reads back false - the identical result an unlocked door in the current room would give. It is not possible to tell "unlocked" apart from "not currently loaded" from this function alone.

On the GBA

A locked door still works as an Exit - it can still be ARRIVED AT; only its own SENDING (acting as an Enter door) is blocked. Locking a door never breaks a different door elsewhere whose own destination is this one - the failure mode that would create ("where does the player end up instead?") has no good answer, which is why locking was scoped to sending only. Reads back false for a door_id naming no LIVE instance right now (this room’s own doors only - see this group’s own header), the same as an unlocked one - there is no separate "not found" value. A door NAME that no longer exists is a compile error naming it, not a silent false.

See also: door_lockdoor_unlockdoor_set_mode